<style>
    html{
        background-color: #f2f2f2;
    }
    .content-body{
        background-color: transparent;
    }
    /* 卡片面板 */
    .layui-card{margin-bottom: 10px; border-radius: 2px; background-color: #fff; box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}
    .layui-card:last-child{margin-bottom: 0;}
    .layui-card-header{position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f6f6f6; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}
    .layui-card-body{position: relative; padding: 10px 15px; line-height: 24px;}
    th,td{
        text-align: center;
    }
</style>

<div class="container-fluid">

    <div class="row layui-card">
        <div class="layui-card-body">
            <a href="{:url('index/index')}">主页</a>
            <span>/</span>
            <span>分户分类统计</span>
        </div>
    </div>

    <div class="row layui-card">
        <div class="layui-card-header" style="height: 45px;">
            <div class="form-inline">
                <label>归档年月</label>
                <input id="archive_yearmonth" value="{$archive_yearmonth}" class="form-control" style="width: 120px;">
                &nbsp;&nbsp;&nbsp;&nbsp;
                <button class="btn btn-info btn-sm" onclick="clickStatistics()">统计</button>
                &nbsp;&nbsp;
                <button class="btn btn-default btn-sm" onclick="clickPrint()">打印表格</button>
                &nbsp;&nbsp;
                <button class="btn btn-success btn-sm" onclick="clickExport()">导出Excel</button>
            </div>
        </div>
        <div class="layui-card-body">
            <div class="col-sm-3">
                <span>参与统计的院处级单位</span>
                <div style="border: 1px solid #ddd;width: 100%;height: 500px;padding-left: 10px;overflow-y:auto">
                    <div style="text-align:left">
                        &nbsp;已选定单位：<br>

                        {volist name="college_selected_list" id="vo"}
                        <input name=collegeList[] type=checkbox value="{$vo}" checked="checked">{$vo}<br>
                        {/volist}
                    </div>
                    <br/>
                    <div style="text-align:left">
                        &nbsp;学院列表：<br>{volist name="college_list" id="vo"}
                        <input name=collegeList[] type=checkbox value="{$vo['COLLEGE_NAME']}">{$vo['COLLEGE_NAME']}<br>
                        {/volist}
                    </div>
                    <br/>
                    <div style="text-align:left">
                        &nbsp;非学院列表：<br>{volist name="no_college_list" id="vo"}
                        <input name=collegeList[] type=checkbox value="{$vo['COLLEGE_NAME']}">{$vo['COLLEGE_NAME']}<br>
                        {/volist}
                    </div>

                </div>
                &nbsp;<button class="btn btn-info btn-sm" style="margin-top: 20px" onclick="clickStatistics()">重新统计</button>
            </div>
            <div class="col-sm-9" style="height: 600px;overflow-y:auto ">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>所属单位</th>
                        <th>下级部门</th>
                        <th>资产类别</th>
                        <th>数量</th>
                        <th>价值（元）</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="fin_list" id="vo"}
                        {if $key == 0}
                            <tr><th rowspan="{$row_num}">&nbsp;天津大学</th>
                                <td rowspan="2">&nbsp;{$vo[0]}</td>
                                <td>&nbsp;{$vo[1]}</td>
                                <td>&nbsp;{$vo[2]}</td>
                                <td>&nbsp;{$vo[3]}</td>
                            </tr>
                            <tr>
                                <td>&nbsp;{$vo[4]}</td>
                                <td>&nbsp;{$vo[5]}</td>
                                <td>&nbsp;{$vo[6]}</td>
                            </tr>
                            {else /}
                            <tr><td rowspan="2">&nbsp;{$vo[0]}</td>
                                <td>&nbsp;{$vo[1]}</td>
                                <td>&nbsp;{$vo[2]}</td>
                                <td>&nbsp;{$vo[3]}</td>
                            </tr>
                            <tr>
                                <td>&nbsp;{$vo[4]}</td>
                                <td>&nbsp;{$vo[5]}</td>
                                <td>&nbsp;{$vo[6]}</td>
                            </tr>
                        {/if}
                    {/volist}
                    <tr>
                        <td rowspan="2">&nbsp;合计</td>
                        <td>&nbsp;设备</td>
                        <td>&nbsp;{$equip_sum_asset_num}</td>
                        <td>&nbsp;{$equip_sum_asset_price}</td>
                    </tr>
                    <tr>
                        <td>&nbsp;家具</td>
                        <td>&nbsp;{$furn_sum_asset_num}</td>
                        <td>&nbsp;{$furn_sum_asset_price}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>

    </div>
    <div class="row layui-card">
        <div id="chart-num" style="width: 100%;height: 600px;padding-top: 30px"></div>
    </div>
    <div class="row layui-card">
        <div id="chart-price" style="width: 100%;height: 600px;padding-top: 30px"></div>
    </div>
</div>

<script src="__STATIC__/js/echarts.min.js"></script>

<script>
    // echarts 表
    var fin_list = {:json_encode($fin_list)};
    var numChart = echarts.init(document.getElementById('chart-num'));
    var priceChart = echarts.init(document.getElementById('chart-price'));
    // 学院列表 数据列表
    var collegeNames = [];
    var series_num1 = [];
    var series_num2 = [];


    var series_price1 = [];
    var series_price2 = [];

    for (var i in fin_list)
    {
        collegeNames.push(fin_list[i][0]);
        series_num1.push(fin_list[i][2]);
        series_num2.push(fin_list[i][5]);

        series_price1.push(fin_list[i][3]);
        series_price2.push(fin_list[i][6]);
    }

    // 指定图表的配置项和数据--数量
    var option_num = {
        title: {
            text: '大型仪器统计--数量'
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        legend: {
            data:['设备','家具']
        },
        xAxis: {
            data: collegeNames
        },
        yAxis: {},
        series: [{
            name: '设备',
            type: 'bar',
            barWidth:"20%",
            data: series_num1
        },{
            name: '家具',
            type: 'bar',
            barWidth:"20%",
            data: series_num2
        }]
    };

    // 指定图表的配置项和数据--价值

    var option_price = {
        title: {
            text: '大型仪器统计--价值'
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        legend: {
            data:['设备','家具']
        },
        xAxis: {
            data: collegeNames
        },
        yAxis: {},
        series: [{
            name: '设备',
            type: 'bar',
            barWidth:"20%",
            data: series_price1
        },{
            name: '家具',
            type: 'bar',
            barWidth:"20%",
            data: series_price2
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    numChart.setOption(option_num);
    priceChart.setOption(option_price);



    function clickStatistics() {
        var collegeList = [];
        $.each($('input:checkbox:checked'),function(){
            collegeList.push($(this).val());
        });
        var archive_yearmonth = $("#archive_yearmonth").val();
        var statisticsType = $("select[name=statisticsType]").val();

        var url = "{:url('statistics/classifyInfo')}?archive_yearmonth="+archive_yearmonth+"&collegeList="+collegeList;
        location.href = url;
    }

    function clickPrint() {
        var collegeList = [];
        $.each($('input:checkbox:checked'),function(){
            collegeList.push($(this).val());
        });
        var archive_yearmonth = $("#archive_yearmonth").val();
        var statisticsType = $("select[name=statisticsType]").val();

        var url = "{:url('statistics/printClassifyInfo')}?archive_yearmonth="+archive_yearmonth+"&collegeList="+collegeList;
        window.open(url);
    }

    function clickExport() {
        var ym = $("#ym").val();
        if(ym == ''){
            layer.alert('请输入归档年月，如：2018-10',{icon:2});
            return;
        }
        location.href = "{:url('statistics/exportClassifyInfo')}?ym=" + ym;
    }



</script>